#include "TSTEPData.h"
#include "DataStructure/Common/Validation.h"

using namespace SG::DataStructure::FEM;

std::vector<SG::DataStructure::Common::Real> SG::DataStructure::FEM::TSTEPData::GetComputeTimeVector () const
{
    std::vector<SG::DataStructure::Common::Real> t;
    SG::DataStructure::Common::Real current_time = 0.0;
    t.push_back(current_time);

    for (const auto& TList : m_TList)
    {
        for (SG::DataStructure::Common::I64 i = 1; i < TList.m_N + 1; ++i)
        {
            current_time += TList.m_DT;
            t.push_back(current_time);
        }
    }

    return t;
}

std::vector<SG::DataStructure::Common::Real> SG::DataStructure::FEM::TSTEPData::GetOutputTimeVector () const
{
    std::vector<SG::DataStructure::Common::Real> t;
    SG::DataStructure::Common::Real current_time = 0.0;
    t.push_back (current_time);

    for (const auto& TList : m_TList)
    {
        for (SG::DataStructure::Common::I64 i = 1; i < TList.m_N + 1; ++i)
        {
            current_time += TList.m_DT;
            if (i % TList.m_NO == 0)
                t.push_back (current_time);
        }
    }

    return t;
}

bool SG::DataStructure::FEM::operator== (const TSTEPData::TData& val1, const TSTEPData::TData& val2)
{
    FIELD_COMPARE (m_N)
    FIELD_COMPARE (m_DT)
    FIELD_COMPARE (m_NO)
    return true;
}

bool SG::DataStructure::FEM::operator== (const TSTEPData& val1, const TSTEPData& val2)
{
    FIELD_COMPARE (m_sId)
    FIELD_COMPARE (m_domainId)
    return true;
}